import csv

from api import BiliAPI

if __name__ == '__main__':
    uid = input("Please input your Bilibili UID: ")
    follow_status = input("Please input follow status(2. wanna watch 3. watched): ")

    bili = BiliAPI(uid, follow_status)

    counter = 0

    with open(f'./{uid}_{follow_status}.csv', mode='w+') as f:
        writer = csv.writer(f)
        writer.writerow(['title', 'cover'])
        for item in bili:
            counter = counter + 1
            writer.writerow([item['title'], item['cover']])
            print(item)

        print(f'write {counter} record to csv, finished!')
